<?php

class CarsAction extends Action {

	public $cars;

    //车辆信息列表
    public function carlist() {
		$o_order = M("cars");
		import("ORG.Util.Page");
		$count = $o_order->count();
		$listrow = 10;
		$page = new Page($count, $listrow);
		$show = $page->show();
		$list =  $o_order->order('car_id')->limit($page->firstRow . "," . $page->listRows)->select();
		$this->assign('lists', $list);
		$this->show = $show;
		$this->display();
    }

	/**
	 * 修改车辆信息
	 */
	 
	public function edit() {
		if (IS_GET) {
			$data = I('get.');
			$model = M('cars');
			$cars = $model->where('car_id="' . $data['car_id'] . '"')->find();

			$this->assign('list',$cars);
			$this->display();
		}
		if (IS_POST) {
			$datas = I('post.');
			$model = M('cars');
			$result =  $model->where('car_id="' . $datas['car_id'] . '"')->save($datas);
			if($result){
				$this->success('修改成功', U('Cars/carlist'));
			}else{
				$this->error('修改失败', U('Cars/carlist'));
			}
		}
		
	}



}